package com.university.mentalhealthplatform.teacherV2.service;



import com.university.mentalhealthplatform.appModels.FamilyMessage;
import com.university.mentalhealthplatform.teacherV2.repository.FamilyMessageRepositoryV2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FamilyMessageServiceV2 {

    @Autowired
    private FamilyMessageRepositoryV2 familyMessageRepositoryV2;

    public FamilyMessage saveFamilyMessage(FamilyMessage familyMessage) {
        return familyMessageRepositoryV2.save(familyMessage);
    }

    public FamilyMessage getFamilyMessageById(Long id) {
        return familyMessageRepositoryV2.findById(id).orElse(null);
    }

    public List<FamilyMessage> getAllFamilyMessages() {
        return familyMessageRepositoryV2.findAll();
    }

    public FamilyMessage updateFamilyMessage(FamilyMessage familyMessage) {
        return familyMessageRepositoryV2.save(familyMessage);
    }

    public void deleteFamilyMessage(Long id) {
        familyMessageRepositoryV2.deleteById(id);
    }

    public List<FamilyMessage> searchFamilyMessages(String keyword) {
        return familyMessageRepositoryV2.findByKeyword(keyword);
    }
}